package cn.tom.service.impl;

import cn.tom.entity.InformationType;
import cn.tom.mapper.InformationTypeMapper;
import cn.tom.service.InformationTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InformationTypeServiceImpl implements InformationTypeService {
    @Autowired
    InformationTypeMapper informationTypeMapper;    //注入InformationTypeMapper接口

    /**
     * 查询资讯全部类型
     */
    @Override
    public List<InformationType> findAll() {
        List<InformationType> informationTypes = informationTypeMapper.selectList(null);
        return informationTypes;
    }

    /**
     * 根据ID查询类型
     */
    @Override
    public InformationType findById(Integer id) {
        InformationType informationType = informationTypeMapper.selectById(id);
        return informationType;
    }

    /**
     * 添加一个资讯类型
     */
    @Override
    public int add(InformationType informationType) {
        int insert = informationTypeMapper.insert(informationType);
        return insert;
    }

    /**
     * 根据资讯类型id更新资讯类型
     */
    @Override
    public int update(InformationType informationType) {
        int i = informationTypeMapper.updateById(informationType);
        return i;
    }

    /**
     * 删除一个资讯类型
     */
    @Override
    public int del(Integer id) {
        int delete = informationTypeMapper.deleteById(id);
        return delete;
    }
}
